package com.andy.fastjson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class TestJson {
	
	public static void main(String[] args) {
		testToString();
		testToObj();
	}
	
	public static void testToString(){
		User user = new User("1", "cui", 56);
		System.out.println(JSON.toJSONString(user));
	}
	public static void testToObj(){
		String text = "{\"user\":{\"age\":56,\"id\":\"1\",\"name\":\"cui\"}}";
		User user = ((JSONObject)JSON.parse(text)).getObject("user", User.class);
		System.out.println(user.getAge());
	}
}
